<?php

if (isset($_COOKIE['anketa']) && $_COOKIE['anketa'] == 'glasao') {
    $PoolFirstAnswers = countPoolFirstAnswers();
    $PoolSecoundAnswers = countPoolSecoundAnswers();
    $PoolThirdAnswers = countPoolThirdAnswers();
    $PoolFourthAnswers = countPoolFourthAnswers();
    
    $ukupnoGlasova=$PoolFirstAnswers+$PoolSecoundAnswers+$PoolThirdAnswers+$PoolFourthAnswers;

$firstAnswersPercentage = round($PoolFirstAnswers * 100 / $ukupnoGlasova, 1 );
$secoundAnswersPercentage = round($PoolSecoundAnswers * 100 / $ukupnoGlasova, 1);
$thirdAnswersPercentage = round($PoolThirdAnswers * 100 / $ukupnoGlasova , 1);
$fourthAnswersPercentage = round($PoolFourthAnswers * 100 / $ukupnoGlasova , 1);


    $smarty->assign('PoolFirstAnswers', $PoolFirstAnswers);
    $smarty->assign('PoolSecoundAnswers', $PoolSecoundAnswers);
    $smarty->assign('PoolThirdAnswers', $PoolThirdAnswers);
    $smarty->assign('PoolFourthAnswers', $PoolFourthAnswers);
    
    $smarty->assign('firstAnswersPercentage', $firstAnswersPercentage);
    $smarty->assign('secoundAnswersPercentage', $secoundAnswersPercentage);
    $smarty->assign('thirdAnswersPercentage', $thirdAnswersPercentage);
    $smarty->assign('fourthAnswersPercentage', $fourthAnswersPercentage);
    
    
    
    $pool = $smarty->fetch('pool_result.tpl');
} else {
    $pool = $smarty->fetch('pool.tpl');
}
?>
